<template>
  <div>
    <van-index-bar>
      <div v-for="v in menu" :key="v.id">
        <van-index-anchor :index="v.word" />
        <van-cell
          :title="item.title"
          v-for="item in v.subMenuList"
          :key="item.id"
					@click="toDetail(item)"
        />
      </div>
    </van-index-bar>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  computed: {
    ...mapGetters(["menu"]),
  },
  created() {
    this.$store.dispatch({ type: "GET_MENU" });
  },
	methods: {
		toDetail(item) {
			console.log(item);
			// 查询字符串
			// this.$router.push(`/detail?id=${item.id}`)
			// this.$router.push({ name: 'Detail', query: { id: item.id } })

			// 动态路由
			// this.$router.push(`/detail/${item.id}`)
			this.$router.push({ name: 'Detail', params: { id: item.id } })
		}
	}
};
</script>



